<?php

define(TH_TEMPLATE_URL, get_bloginfo('template_url') . "/");

add_action('wp_print_scripts', 'my_deregister_javascript', 100);

function my_deregister_javascript() {
  //wp_deregister_script( 'jquery' );
}

function my_scripts_method() {

//JAVASCRIPT
  wp_deregister_script('jquery-ui-core'); //deregistro il jquery ui di WP lo includo nell'header
  //wp_deregister_script('jquery'); //deregistro il jquery ui di WP lo includo nell'header
}

add_action('wp_enqueue_style', 'my_styles_method');

function my_styles_method() {


//CSS
  wp_register_style("base", TH_TEMPLATE_URL . "/css/base.css", array(), 1.0, false);
  wp_register_style("booking_form", TH_TEMPLATE_URL . "/css/booking_form.css", array(), 1.0, false);
  wp_register_style("ex", TH_TEMPLATE_URL . "/css/ex.css", array(), 1.0, false);
  wp_register_style("ie", TH_TEMPLATE_URL . "/css/ie.css", array(), 1.0, false);
  wp_register_style("ie8", TH_TEMPLATE_URL . "/css/ie8.css", array(), 1.0, false);
  wp_register_style("print", TH_TEMPLATE_URL . "/css/print.css", array(), 1.0, false);
  wp_register_style("reset", TH_TEMPLATE_URL . "/css/reset.css", array(), 1.0, false);
  wp_register_style("screen", TH_TEMPLATE_URL . "/css/screen.css", array(), 1.0, false);

  wp_enqueue_style('base');
  wp_enqueue_style('booking_form');
  wp_enqueue_style('ex');
  wp_enqueue_style('ie');
  wp_enqueue_style('ie8');
  wp_enqueue_style('print');
  wp_enqueue_style('reset');
  wp_enqueue_style('screen');
}

function template_url_shortcode($atts) {
  extract(shortcode_atts(array(
              'key' => '',
                  ), $atts));
  return TH_TEMPLATE_URL;
}

add_shortcode('template_url', 'template_url_shortcode');

function seiqui($where) {
  global $post, $wpdb;
  $permalink = get_permalink();
  $postid = $post->ID;
  switch ($where) {
    case "contatti":
      if ($permalink == get_permalink(30))
        return "current";
      break;
    case "chisiamo":
      if ($permalink == get_permalink(15))
        return "current";
      break;
    case "corsi":
      if ($permalink == get_permalink(7))
        return "current";
      break;
    case "servizi":
      if ($permalink == get_permalink(2))
        return "current";
      break;
    case "news":
      if ($permalink == get_permalink(24))
        return "current";
      $query = "SELECT COUNT(*) as conto FROM wp_cuspo_news WHERE wp_post_id='{$postid}'";
      $myrows = $wpdb->get_results($query, ARRAY_A);
      if ($myrows[0]['conto'] == "1")
        return "current_inner";
      break;
    case "concorsi":
      if ($permalink == get_permalink(9))
        return "current";
      $query = "SELECT COUNT(*) as conto FROM wp_cuspo_concorsi WHERE wp_post_id='{$postid}'";
      $myrows = $wpdb->get_results($query, ARRAY_A);
      if ($myrows[0]['conto'] == "1")
        return "current_inner";
      break;
    default:
      break;
  }
  return "not_here";
}

/* AJAX *//* AJAX *//* AJAX *//* AJAX *//* AJAX *//* AJAX *//* AJAX *//* AJAX *//* AJAX *//* AJAX *//* AJAX */
/* AJAX *//* AJAX *//* AJAX *//* AJAX *//* AJAX *//* AJAX *//* AJAX *//* AJAX *//* AJAX *//* AJAX *//* AJAX */
/* AJAX *//* AJAX *//* AJAX *//* AJAX *//* AJAX *//* AJAX *//* AJAX *//* AJAX *//* AJAX *//* AJAX *//* AJAX */

require_once "funzioniAjax.php";
add_action("wp_ajax_nopriv_contatta", "contatta");
add_action("wp_ajax_contatta", "contatta");
?>
